package com.ctshk.sapp.order.train.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.TokenUser;
import com.ctshk.rpc.order.train.dto.TrainOrderDetailDTO;
import com.ctshk.rpc.order.train.dto.TrainOrderReceiptDTO;
import com.ctshk.rpc.order.train.req.TrainOrderReceiptReq;
import com.ctshk.rpc.order.train.req.TrainPlaceOrderReq;
import com.ctshk.rpc.order.train.service.ITrainOrderReceiptService;
import com.ctshk.rpc.order.train.service.ITrainOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 火车订单收据 前端控制器
 * </p>
 *
 * @author 彭柳霖
 * @since 2021-03-18
 */
@Api(value="订单中心-收据管理", tags="订单中心-收据管理")
@RestController
@RequestMapping("/train-order-receipt")
public class TrainOrderReceiptController extends BaseController {

    @DubboReference
    private ITrainOrderReceiptService trainOrderReceiptService;

    @ApiOperation(value = "火车票-订单中心-保存收据", notes = "火车票-订单中心-保存收据")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "火车票-订单中心-保存收据", operDesc = "火车票-订单中心-保存收据")
    @PostMapping("/addOrder")
    public Result saveTrainReceipt(@Valid @RequestBody TrainOrderReceiptReq trainOrderReceiptReq) {
        TokenUser currentUser = getCurrentUser(getRequest());
        return trainOrderReceiptService.saveTrainReceipt(trainOrderReceiptReq, currentUser);
    }

    @ApiOperation(value = "订单中心-查询收据详情", notes = "订单中心-查询收据详情")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "订单中心-查询收据详情", operDesc = "订单中心-查询收据详情")
    @GetMapping(value = "/queryOrderReceiptInfo/{orderId}")
    public Result<TrainOrderReceiptDTO> queryOrderReceiptInfo(@PathVariable Long orderId){
        return trainOrderReceiptService.queryOrderReceiptInfo(orderId);
    }
}
